class SyncWaterfallHook { // 钩子是同步的
  constructor(args) {
    this.task = []
  }
  tap(name, task) {
    this.task.push(task)
  }

  call(...args) {
    this.task.reduce((res, cur) => {
      return cur(res)
    }, ...args)
  }
}

const hook = new SyncWaterfallHook(['name'])
hook.tap('react', function (name) {
  console.log('react', name)
  return 'react ok'
})

hook.tap('node', function (data) {
  console.log('node', data)
  return 'node ok'
})
hook.tap('webpack', function (data) {
  console.log('node', data)
})

hook.call('jw')